#ifndef FILESYSTEM_H_INCLUDED
#define FILESYSTEM_H_INCLUDED

#include "File.h"
#include "FilePath.h"
#include "Atomic.h"

namespace CEngine
{

namespace FileSystem {

    ///Structure containing information of the file/directory listed by listDirectory.
    struct FileInfo {
        FilePath fileName;
        U64 timeLastModified;
        U64 size;
        bool isDirectory;
    };

    ///Initializes the File System.
    void
    initialize(void);

    ///Moves the given file to the new path.
    ///returns if it was successful or not.
    bool
    move(const FilePath& currentPath, const FilePath& newPath);

    ///Same as above, but re-opens the file afterwards if it was open.
    bool
    move(File& currentFile, const FilePath& newPath);

    ///Copies the given file to the new path.
    ///returns if it was successful or not.
    bool
    copy(const FilePath& currentPath, const FilePath& newPath, bool overwrite = true);

    ///same as above, but re-opens the file afterward if it was open.
    bool
    copy(File& currentFile, const FilePath& newPath, bool overwrite = true);

    ///Marks the given file for deletion after it has been closed.
    ///If closeFile isn't true the file will not be closed.
    bool
    remove(File& file, const bool closeFile = true);

    ///Marks the file/directory at the given path for deletion after it has been closed.
    bool
    remove(const FilePath& path);

    ///Converts a relative Path to an absolute path based on the base path.
    void
    relativeToAbsolute(FilePath& path);

    ///Converts an absolute Path to a relative path based on the base path.
    void
    absoluteToRelative(FilePath& path);

    ///Lists the contents of a given directory one entry at a time.
    ///If directory is NULL or the same as last time it will continue searching the previous directory.
    ///Returns if an entry was successfully read, will be false and entry left blank if an invalid path is given,
    ///or if the directory has been fully listed.
    bool
    listDirectory(FileInfo& entry, FilePath* directory = NULL);

    ///returns a string to the directory where the program is.
    ///All relative paths should be be based off this.
    CHAR*
    getBasePath(void);
}

}

#endif // FILESYSTEM_H_INCLUDED
